<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div id="app">
    <h2>{{msg}}</h2>
    <!-- 作用: 数据在子组件中,但是父组件向换一种方式展示
         1. 在子组件中设置需要使用的数据:data="pLanguage"
         2. 在父组件使用slot-scope='slot'声明, 然后是使用slot.data引用子组件中的数据-->
    <cpn></cpn>
    <cpn>
        <!-- -->
        <template slot-scope="slot">
            <span v-for="item in slot.data"> {{item}}-- </span>
        </template>
    </cpn>

    <cpn>
        <!-- -->
        <template slot-scope="slot">
            <span> {{slot.data.join(' - ')}}</span>
        </template>
    </cpn>

</div>

<template id="cpn">
    <div>
        <slot :data="pLanguage">
            <ul>
                <li v-for="item in pLanguage"> {{item}}</li>
            </ul>
        </slot>

    </div>
</template>
<script src="../js/vue.js"></script>
<script>

    const cpn = {
        template: "#cpn",
        data() {
            return {
                pLanguage: ['java','python', 'c/c++', 'go', 'c#']
            }
        }
    }
    const app = new Vue({
        el: "#app",
        data: {
            msg: "hello"
        },
        components: {
            cpn: cpn
        }
    })
</script>

</body>
</html>